home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 60 / 60.xpi / chrome / webdeveloper.jar / content / webdeveloper / information.js < prev    next >
Text File  |  2009-06-30  |  93KB  |  2,308 lines

  1. // Adds colors from the specified property of the element to the given list
  2. function webdeveloper_addColor(element, property, colorList)
  3. {
  4.     // If the element, property and color list are set
  5.     if(element && property && colorList)
  6.     {
  7.         var computedStyle = element.ownerDocument.defaultView.getComputedStyle(element, null);
  8.         var color         = computedStyle.getPropertyCSSValue(property);
  9.  
  10.         // If the color is set and it is a color
  11.         if(color && color.primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR)
  12.         {
  13.             color = color.getRGBColorValue();
  14.  
  15.             colorList.push("#" + webdeveloper_formatColor(color.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)) + webdeveloper_formatColor(color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)) + webdeveloper_formatColor(color.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)));
  16.         }
  17.     }
  18. }
  19.  
  20. // Displays all abbreviations
  21. function webdeveloper_displayAbbreviations(element)
  22. {
  23.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_abbreviations.css", "webdeveloper-display-abbreviations");
  24.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-abbreviations-tooltips", "*:before");
  25. }
  26.  
  27. // Displays all access keys
  28. function webdeveloper_displayAccessKeys(element)
  29. {
  30.     var accessKeyElement        = null;
  31.     var accessKeyElementList    = null;
  32.     var accessKeyElementsLength = null;
  33.     var display                 = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  34.     var documentList            = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  35.     var documentLength          = documentList.length;
  36.     var pageDocument            = null;
  37.     var spanElement             = null;
  38.     var text                    = null;
  39.  
  40.     // Loop through the documents
  41.     for(var i = 0; i < documentLength; i++)
  42.     {
  43.         pageDocument = documentList[i];
  44.  
  45.         // Need to do this to stop the feature running twice
  46.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-access-keys']");
  47.  
  48.         // If displaying
  49.         if(display)
  50.         {
  51.             accessKeyElementList    = webdeveloper_evaluateXPath(pageDocument, "//*[@accesskey]");
  52.             accessKeyElementsLength = accessKeyElementList.length;
  53.  
  54.             // Loop through all the access key elements
  55.             for(var j = 0; j < accessKeyElementsLength; j++)
  56.             {
  57.                 accessKeyElement = accessKeyElementList[j];
  58.                 spanElement      = pageDocument.createElement("span");
  59.                 text             = "Accesskey=" + accessKeyElement.getAttribute("accesskey");
  60.  
  61.                 spanElement.setAttribute("class", "webdeveloper-display-access-keys");
  62.                 spanElement.setAttribute("title", text);
  63.                 spanElement.appendChild(pageDocument.createTextNode(text));
  64.                 accessKeyElement.parentNode.insertBefore(spanElement, accessKeyElement);
  65.             }
  66.         }
  67.     }
  68.  
  69.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-access-keys");
  70.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-access-keys-tooltips", "span.webdeveloper-display-access-keys");
  71. }
  72.  
  73. // Displays all anchors
  74. function webdeveloper_displayAnchors(element)
  75. {
  76.     var anchorElement        = null;
  77.     var anchorElementList    = null;
  78.     var anchorElementsLength = null;
  79.     var anchorLocation       = null;
  80.     var anchorText           = null;
  81.     var display              = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  82.     var documentList         = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  83.     var documentLength       = documentList.length;
  84.     var linkElement          = null;
  85.     var pageDocument         = null;
  86.     var pageLocation         = null;
  87.     var spanElement          = null;
  88.  
  89.     // Loop through the documents
  90.     for(var i = 0; i < documentLength; i++)
  91.     {
  92.         pageDocument = documentList[i];
  93.  
  94.         // Need to do this to stop the feature running twice
  95.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-anchors']");
  96.  
  97.         // If displaying
  98.         if(display)
  99.         {
  100.             anchorElementList    = webdeveloper_evaluateXPath(pageDocument, "//*[@id] | //a[@name]");
  101.             anchorElementsLength = anchorElementList.length;
  102.             pageLocation         = pageDocument.location;
  103.             anchorLocation       = pageLocation.pathname + pageLocation.search;
  104.  
  105.             // Loop through all the anchor elements
  106.             for(var j = 0; j < anchorElementsLength; j++)
  107.             {
  108.                 anchorElement = anchorElementList[j];
  109.                 linkElement   = pageDocument.createElement("a");
  110.                 spanElement   = pageDocument.createElement("span");
  111.  
  112.                 // If the anchor element has an id attribute
  113.                 if(anchorElement.hasAttribute("id"))
  114.                 {
  115.                     anchorText = "#" + anchorElement.getAttribute("id");
  116.                 }
  117.                 else if(anchorElement.hasAttribute("name"))
  118.                 {
  119.                     anchorText = "#" + anchorElement.getAttribute("name");
  120.                 }
  121.  
  122.                 linkElement.setAttribute("href", anchorLocation + anchorText);
  123.                 linkElement.setAttribute("title", anchorText);
  124.                 linkElement.appendChild(pageDocument.createTextNode(anchorText));
  125.  
  126.                 spanElement.setAttribute("class", "webdeveloper-display-anchors");
  127.                 spanElement.setAttribute("title", anchorText);
  128.                 spanElement.appendChild(linkElement);
  129.  
  130.  
  131.                 // Try to insert the anchor element
  132.                 try
  133.                 {
  134.                     anchorElement.parentNode.insertBefore(spanElement, anchorElement);
  135.                 }
  136.                 catch(exception)
  137.                 {
  138.                     // Do nothing
  139.                 }
  140.             }
  141.         }
  142.     }
  143.  
  144.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_anchors.css", "webdeveloper-display-anchors");
  145.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-anchors-tooltips", "span.webdeveloper-display-anchors, span.webdeveloper-display-anchors a");
  146. }
  147.  
  148. // Displays all block sizes
  149. function webdeveloper_displayBlockSize(element)
  150. {
  151.     var blockSizeElement        = null;
  152.     var blockSizeElementList    = null;
  153.     var blockSizeElementsLength = null;
  154.     var display                 = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  155.     var documentList            = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  156.     var documentLength          = documentList.length;
  157.     var height                  = null;
  158.     var left                    = null;
  159.     var pageDocument            = null;
  160.     var spanElement             = null;
  161.     var text                    = null;
  162.     var top                     = null;
  163.     var width                   = null;
  164.  
  165.     // Loop through the documents
  166.     for(var i = 0; i < documentLength; i++)
  167.     {
  168.         pageDocument = documentList[i];
  169.  
  170.         // Need to do this to stop the feature running twice
  171.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-block-size']");
  172.  
  173.         // If displaying
  174.         if(display)
  175.         {
  176.             blockSizeElementList    = webdeveloper_evaluateXPath(pageDocument, "//div | //form | //table");
  177.             blockSizeElementsLength = blockSizeElementList.length;
  178.  
  179.             // Loop through the block size elements
  180.             for(var j = 0; j < blockSizeElementsLength; j++)
  181.             {
  182.                 blockSizeElement = blockSizeElementList[j];
  183.                 height           = blockSizeElement.offsetHeight;
  184.                 left             = blockSizeElement.offsetLeft;
  185.                 spanElement      = pageDocument.createElement("span");
  186.                 top              = blockSizeElement.offsetTop;
  187.                 width            = blockSizeElement.offsetWidth;
  188.                 text             = webdeveloper_getElementDescription(blockSizeElement) + " " + width + "x" + height;
  189.  
  190.                 spanElement.style.left     = left + "px";
  191.                 spanElement.style.position = "absolute";
  192.                 spanElement.style.top      = top + "px";
  193.  
  194.                 spanElement.setAttribute("class", "webdeveloper-display-block-size");
  195.                 spanElement.setAttribute("title", text);
  196.                 spanElement.appendChild(pageDocument.createTextNode(text));
  197.  
  198.                 webdeveloper_insertAsFirstChild(blockSizeElement, spanElement);
  199.             }
  200.         }
  201.     }
  202.  
  203.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_block_size.css", "webdeveloper-display-block-size");
  204.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-block-size-tooltips", "span.webdeveloper-display-block-size");
  205. }
  206.  
  207. // Displays the order of the divs on the page
  208. function webdeveloper_displayDivOrder(element)
  209. {
  210.     var display            = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  211.     var divElement         = null;
  212.     var divElementList     = null;
  213.     var divElementsLength  = null;
  214.     var documentList       = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  215.     var documentLength     = documentList.length;
  216.     var pageDocument       = null;
  217.     var spanElement        = null;
  218.     var text               = null;
  219.  
  220.     // Loop through the documents
  221.     for(var i = 0; i < documentLength; i++)
  222.     {
  223.         pageDocument = documentList[i];
  224.  
  225.         // Need to do this to stop the feature running twice
  226.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-div-order']");
  227.  
  228.         // If displaying
  229.         if(display)
  230.         {
  231.             divElementList    = pageDocument.getElementsByTagName("div");
  232.             divElementsLength = divElementList.length;
  233.  
  234.             // Loop through the div elements
  235.             for(var j = 0; j < divElementsLength; j++)
  236.             {
  237.                 divElement  = divElementList[j];
  238.                 spanElement = pageDocument.createElement("span");
  239.                 text        = webdeveloper_getElementDescription(divElement) + " " + (j + 1);
  240.  
  241.                 spanElement.setAttribute("class", "webdeveloper-display-div-order");
  242.                 spanElement.setAttribute("title", text);
  243.                 spanElement.appendChild(pageDocument.createTextNode(text));
  244.  
  245.                 webdeveloper_insertAsFirstChild(divElement, spanElement);
  246.             }
  247.         }
  248.     }
  249.  
  250.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_div_order.css", "webdeveloper-display-div-order");
  251.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-div-order-tooltips", "span.webdeveloper-display-div-order");
  252. }
  253.  
  254. // Displays id and class details for the page
  255. function webdeveloper_displayIdClassDetails(element)
  256. {
  257.     var display               = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  258.     var documentList          = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  259.     var documentLength        = documentList.length;
  260.     var idClassElement        = null;
  261.     var idClassElementList    = null;
  262.     var idClassElementsLength = null;
  263.     var idClassElementText    = null;
  264.     var pageDocument          = null;
  265.     var spanElement           = null;
  266.  
  267.     // Loop through the documents
  268.     for(var i = 0; i < documentLength; i++)
  269.     {
  270.         pageDocument = documentList[i];
  271.  
  272.         // Need to do this to stop the feature running twice
  273.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-id-class-details']");
  274.  
  275.         // If displaying
  276.         if(display)
  277.         {
  278.             idClassElementList    = webdeveloper_evaluateXPath(pageDocument, "//*[@class] | //*[@id]");
  279.             idClassElementsLength = idClassElementList.length;
  280.  
  281.             // Loop through all the id class elements
  282.             for(var j = 0; j < idClassElementsLength; j++)
  283.             {
  284.                 idClassElement = idClassElementList[j];
  285.  
  286.                 // If the id class element is a Web Developer element
  287.                 if((idClassElement.hasAttribute("class") && idClassElement.getAttribute("class").indexOf("webdeveloper-")) || (idClassElement.hasAttribute("id") && idClassElement.getAttribute("id").indexOf("webdeveloper-")))
  288.                 {
  289.                     idClassElementText = "";
  290.                     spanElement        = pageDocument.createElement("span");
  291.  
  292.                     // If the id class element has an id attribute
  293.                     if(idClassElement.hasAttribute("id"))
  294.                     {
  295.                         idClassElementText += " #" + idClassElement.getAttribute("id");
  296.                     }
  297.  
  298.                     // If the id class element has a class attribute
  299.                     if(idClassElement.hasAttribute("class"))
  300.                     {
  301.                         idClassElementText += " ." + idClassElement.getAttribute("class");
  302.                     }
  303.  
  304.                     spanElement.setAttribute("class", "webdeveloper-display-id-class-details");
  305.                     spanElement.setAttribute("title", idClassElementText);
  306.                     spanElement.appendChild(pageDocument.createTextNode(idClassElementText));
  307.  
  308.                     // Try to insert the id class element
  309.                     try
  310.                     {
  311.                         idClassElement.parentNode.insertBefore(spanElement, idClassElement);
  312.                     }
  313.                     catch(exception)
  314.                     {
  315.                         // Do nothing
  316.                     }
  317.                 }
  318.             }
  319.         }
  320.     }
  321.  
  322.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-id-class-details");
  323.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-id-class-details-tooltips", "span.webdeveloper-display-id-class-details");
  324. }
  325.  
  326. // Displays all link details
  327. function webdeveloper_displayLinkDetails(element)
  328. {
  329.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_link_details.css", "webdeveloper-display-link-details");
  330.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-link-details-tooltips", "*:before");
  331. }
  332.  
  333. // Displays object information
  334. function webdeveloper_displayObjectInformation(element)
  335. {
  336.     var checked              = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  337.     var divElement           = null;
  338.     var documentList         = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  339.     var documentLength       = documentList.length;
  340.     var objectAttributes     = null;
  341.     var objectElement        = null;
  342.     var objectElementList    = null;
  343.     var objectElementsLength = null;
  344.     var pageDocument         = null;
  345.     var paramAttributes      = null;
  346.     var paramElement         = null;
  347.     var paramElementList     = null;
  348.     var paramElementsLength  = null;
  349.     var pElement             = null;
  350.     var treeWalker           = null;
  351.  
  352.     // Loop through the documents
  353.     for(var i = 0; i < documentLength; i++)
  354.     {
  355.         pageDocument = documentList[i];
  356.  
  357.         // Need to do this to stop the feature running twice
  358.         webdeveloper_removeAllElementsByXPath(pageDocument, "//div[@class='webdeveloper-display-object-information']");
  359.  
  360.         // If the element is checked
  361.         if(checked)
  362.         {
  363.             objectElementList    = pageDocument.getElementsByTagName("object");
  364.             objectElementsLength = objectElementList.length;
  365.  
  366.             // Loop through all the object elements
  367.             for(var j = 0; j < objectElementsLength; j++)
  368.             {
  369.                 divElement          = pageDocument.createElement("div");
  370.                 objectAttributes    = "";
  371.                 objectElement       = objectElementList[j];
  372.                 paramElementList    = objectElement.getElementsByTagName("param");
  373.                 paramElementsLength = paramElementList.length;
  374.                 pElement            = pageDocument.createElement("p");
  375.  
  376.                 // If the object has an width attribute
  377.                 if(objectElement.hasAttribute("width"))
  378.                 {
  379.                     objectAttributes += ' width="' + objectElement.getAttribute("width") + '"';
  380.                 }
  381.  
  382.                 // If the object has an height attribute
  383.                 if(objectElement.hasAttribute("height"))
  384.                 {
  385.                     objectAttributes += ' height="' + objectElement.getAttribute("height") + '"';
  386.                 }
  387.  
  388.                 // If the object has an archive attribute
  389.                 if(objectElement.hasAttribute("archive"))
  390.                 {
  391.                     objectAttributes += ' archive="' + objectElement.getAttribute("archive") + '"';
  392.                 }
  393.  
  394.                 // If the object has an classid attribute
  395.                 if(objectElement.hasAttribute("classid"))
  396.                 {
  397.                     objectAttributes += ' classid="' + objectElement.getAttribute("classid") + '"';
  398.                 }
  399.  
  400.                 // If the object has an codebase attribute
  401.                 if(objectElement.hasAttribute("codebase"))
  402.                 {
  403.                     objectAttributes += ' codebase="' + objectElement.getAttribute("codebase") + '"';
  404.                 }
  405.  
  406.                 // If the object has an codetype attribute
  407.                 if(objectElement.hasAttribute("codetype"))
  408.                 {
  409.                     objectAttributes += ' codetype="' + objectElement.getAttribute("codetype") + '"';
  410.                 }
  411.  
  412.                 // If the object has an data attribute
  413.                 if(objectElement.hasAttribute("data"))
  414.                 {
  415.                     objectAttributes += ' data="' + objectElement.getAttribute("data") + '"';
  416.                 }
  417.  
  418.                 // If the object has an standby attribute
  419.                 if(objectElement.hasAttribute("standby"))
  420.                 {
  421.                     objectAttributes += ' standby="' + objectElement.getAttribute("standby") + '"';
  422.                 }
  423.  
  424.                 // If the object has an type attribute
  425.                 if(objectElement.hasAttribute("type"))
  426.                 {
  427.                     objectAttributes += ' type="' + objectElement.getAttribute("type") + '"';
  428.                 }
  429.  
  430.                 pElement.appendChild(document.createTextNode("<object" + objectAttributes + ">"));
  431.                 divElement.appendChild(pElement);
  432.  
  433.                 // Loop through all the param elements
  434.                 for(var k = 0; k < paramElementsLength; k++)
  435.                 {
  436.                     paramAttributes = "";
  437.                     paramElement    = paramElementList[k];
  438.                     pElement        = pageDocument.createElement("p");
  439.  
  440.                     // If the param has a name attribute
  441.                     if(paramElement.hasAttribute("name"))
  442.                     {
  443.                         paramAttributes += ' name="' + paramElement.getAttribute("name") + '"';
  444.                     }
  445.  
  446.                     // If the param has a value attribute
  447.                     if(paramElement.hasAttribute("value"))
  448.                     {
  449.                         paramAttributes += ' value="' + paramElement.getAttribute("value") + '"';
  450.                     }
  451.  
  452.                     pElement.appendChild(document.createTextNode("<param" + paramAttributes + " />"));
  453.                     pElement.setAttribute("class", "param");
  454.                     divElement.appendChild(pElement);
  455.                 }
  456.  
  457.                 pElement = pageDocument.createElement("p");
  458.                 pElement.appendChild(document.createTextNode("</object>"));
  459.                 divElement.appendChild(pElement);
  460.  
  461.                 divElement.setAttribute("class", "webdeveloper-display-object-information");
  462.                 objectElement.parentNode.insertBefore(divElement, objectElement);
  463.             }
  464.         }
  465.     }
  466.  
  467.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_object_information.css", "webdeveloper-display-object-information");
  468.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-object-information-tooltips", "div.webdeveloper-display-object-information");
  469. }
  470.  
  471. // Displays the stack level of all elements on the page
  472. function webdeveloper_displayStackLevels(element)
  473. {
  474.     var display            = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  475.     var documentList       = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  476.     var documentLength     = documentList.length;
  477.     var pageDocument       = null;
  478.     var pageElement        = null;
  479.     var spanElement        = null;
  480.     var text               = null;
  481.     var treeWalker         = null;
  482.  
  483.     // Loop through the documents
  484.     for(var i = 0; i < documentLength; i++)
  485.     {
  486.         pageDocument = documentList[i];
  487.  
  488.         // Need to do this to stop the feature running twice
  489.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-stack-levels']");
  490.  
  491.         // If displaying
  492.         if(display)
  493.         {
  494.             treeWalker = pageDocument.createTreeWalker(pageDocument, NodeFilter.SHOW_ELEMENT, webdeveloper_stackLevelFilter, false);
  495.  
  496.             // While the tree walker has more nodes
  497.             while((pageElement = treeWalker.nextNode()) != null)
  498.             {
  499.                 spanElement = pageDocument.createElement("span");
  500.                 text        = webdeveloper_getElementDescription(pageElement) + " Z-index=" + pageElement.ownerDocument.defaultView.getComputedStyle(pageElement, null).getPropertyCSSValue("z-index").cssText;
  501.  
  502.                 spanElement.setAttribute("class", "webdeveloper-display-stack-levels");
  503.                 spanElement.setAttribute("title", text);
  504.                 spanElement.appendChild(pageDocument.createTextNode(text));
  505.  
  506.                 webdeveloper_insertAsFirstChild(pageElement, spanElement);
  507.             }
  508.         }
  509.     }
  510.  
  511.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-stack-levels");
  512.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-stack-levels-tooltips", "span.webdeveloper-display-stack-levels");
  513. }
  514.  
  515. // Displays all tab indices
  516. function webdeveloper_displayTabIndex(element)
  517. {
  518.     var checked                = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  519.     var documentList           = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  520.     var documentLength         = documentList.length;
  521.     var pageDocument           = null;
  522.     var spanElement            = null;
  523.     var tabIndexElement        = null;
  524.     var tabIndexElementList    = null;
  525.     var tabIndexElementsLength = null;
  526.     var text                   = null;
  527.  
  528.     // Loop through the documents
  529.     for(var i = 0; i < documentLength; i++)
  530.     {
  531.         pageDocument = documentList[i];
  532.  
  533.         // Need to do this to stop the feature running twice
  534.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-tab-index']");
  535.  
  536.         // If the element is checked
  537.         if(checked)
  538.         {
  539.             tabIndexElementList    = webdeveloper_evaluateXPath(pageDocument, "//*[@tabindex]");
  540.             tabIndexElementsLength = tabIndexElementList.length;
  541.  
  542.             // Loop through all the tab index elements
  543.             for(var j = 0; j < tabIndexElementsLength; j++)
  544.             {
  545.                 spanElement     = pageDocument.createElement("span");
  546.                 tabIndexElement = tabIndexElementList[j];
  547.                 text            = "Tabindex=" + tabIndexElement.getAttribute("tabindex");
  548.  
  549.                 spanElement.setAttribute("class", "webdeveloper-display-tab-index");
  550.                 spanElement.setAttribute("title", text);
  551.                 spanElement.appendChild(document.createTextNode(text));
  552.                 tabIndexElement.parentNode.insertBefore(spanElement, tabIndexElement);
  553.             }
  554.         }
  555.     }
  556.  
  557.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-tab-index");
  558.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-tab-index-tooltips", "span.webdeveloper-display-tab-index");
  559. }
  560.  
  561. // Displays the depth of all tables
  562. function webdeveloper_displayTableDepth(element)
  563. {
  564.     var checked             = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  565.     var documentList        = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  566.     var documentLength      = documentList.length;
  567.     var pageDocument        = null;
  568.     var spanElement         = null;
  569.     var stringBundle        = document.getElementById("webdeveloper-string-bundle");
  570.     var tableElement        = null;
  571.     var tableElementList    = null;
  572.     var tableElementsLength = null;
  573.     var text                = null;
  574.  
  575.     // Loop through the documents
  576.     for(var i = 0; i < documentLength; i++)
  577.     {
  578.         pageDocument = documentList[i];
  579.  
  580.         // Need to do this to stop the feature running twice
  581.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-table-depth']");
  582.  
  583.         // If the element is checked
  584.         if(checked)
  585.         {
  586.             tableElementList    = pageDocument.getElementsByTagName("table");
  587.             tableElementsLength = tableElementList.length;
  588.  
  589.             // Loop through all the table elements
  590.             for(var j = 0; j < tableElementsLength; j++)
  591.             {
  592.                 spanElement  = pageDocument.createElement("span");
  593.                 tableElement = tableElementList[j];
  594.                 text         = stringBundle.getString("webdeveloper_depth") + "=" + webdeveloper_getTableDepth(tableElement);
  595.  
  596.                 spanElement.setAttribute("class", "webdeveloper-display-table-depth");
  597.                 spanElement.setAttribute("title", text);
  598.                 spanElement.appendChild(document.createTextNode(text));
  599.                 tableElement.parentNode.insertBefore(spanElement, tableElement);
  600.             }
  601.         }
  602.     }
  603.  
  604.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-table-depth");
  605.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-table-depth-tooltips", "span.webdeveloper-display-table-depth");
  606. }
  607.  
  608. // Displays table information
  609. function webdeveloper_displayTableInformation(element)
  610. {
  611.     var checked                 = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  612.     var divElement              = null;
  613.     var documentList            = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  614.     var documentLength          = documentList.length;
  615.     var pageDocument            = null;
  616.     var tableCellElementList    = null;
  617.     var tableCellElementsLength = null;
  618.     var tableElement            = null;
  619.     var tableElementList        = null;
  620.     var tableElementsLength     = null;
  621.  
  622.     // Loop through the documents
  623.     for(var i = 0; i < documentLength; i++)
  624.     {
  625.         pageDocument = documentList[i];
  626.  
  627.         // Need to do this to stop the feature running twice
  628.         webdeveloper_removeAllElementsByXPath(pageDocument, "//div[@class='webdeveloper-display-table-information']");
  629.  
  630.         // If the element is checked
  631.         if(checked)
  632.         {
  633.             tableElementList    = pageDocument.getElementsByTagName("table");
  634.             tableElementsLength = tableElementList.length;
  635.  
  636.             // Loop through all the table elements
  637.             for(var j = 0; j < tableElementsLength; j++)
  638.             {
  639.                 tableElement            = tableElementList[j];
  640.                 tableCellElementList    = tableElement.getElementsByTagName("th");
  641.                 tableCellElementsLength = tableCellElementList.length;
  642.  
  643.                 // If the table has a summary attribute
  644.                 if(tableElement.hasAttribute("summary"))
  645.                 {
  646.                     divElement = pageDocument.createElement("div");
  647.  
  648.                     divElement.setAttribute("class", "webdeveloper-display-table-information");
  649.                     divElement.appendChild(pageDocument.createTextNode("Summary=" + tableElement.getAttribute("summary")));
  650.                     tableElement.parentNode.insertBefore(divElement, tableElement);
  651.                 }
  652.  
  653.                 // Loop through the cell elements
  654.                 for(var k = 0; k < tableCellElementsLength; k++)
  655.                 {
  656.                     webdeveloper_outputTableCellInformation(tableCellElementList[k], pageDocument);
  657.                 }
  658.  
  659.                 tableCellElementList    = tableElement.getElementsByTagName("td");
  660.                 tableCellElementsLength = tableCellElementList.length;
  661.  
  662.                 // Loop through the cell elements
  663.                 for(k = 0; k < tableCellElementsLength; k++)
  664.                 {
  665.                     webdeveloper_outputTableCellInformation(tableCellElementList[k], pageDocument);
  666.                 }
  667.             }
  668.         }
  669.     }
  670.  
  671.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_table_information.css", "webdeveloper-display-table-information");
  672.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-table-information-tooltips", "div.webdeveloper-display-table-information");
  673. }
  674.  
  675. // Displays all title attributes
  676. function webdeveloper_displayTitleAttributes(element)
  677. {
  678.     var checked                      = webdeveloper_convertToBoolean(element.getAttribute("checked"));
  679.     var documentList                 = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  680.     var documentLength               = documentList.length;
  681.     var pageDocument                 = null;
  682.     var spanElement                  = null;
  683.     var text                         = null;
  684.     var titleAttributeElement        = null;
  685.     var titleAttributeElementList    = null;
  686.     var titleAttributeElementsLength = null;
  687.  
  688.     // Loop through the documents
  689.     for(var i = 0; i < documentLength; i++)
  690.     {
  691.         pageDocument = documentList[i];
  692.  
  693.         // Need to do this to stop the feature running twice
  694.         webdeveloper_removeAllElementsByXPath(pageDocument, "//span[@class='webdeveloper-display-title-attributes']");
  695.  
  696.         // If the element is checked
  697.         if(checked)
  698.         {
  699.             titleAttributeElementList    = webdeveloper_evaluateXPath(pageDocument, "//*[@title]");
  700.             titleAttributeElementsLength = titleAttributeElementList.length;
  701.  
  702.             // Loop through all the title attribute elements
  703.             for(var j = 0; j < titleAttributeElementsLength; j++)
  704.             {
  705.                 spanElement           = pageDocument.createElement("span");
  706.                 titleAttributeElement = titleAttributeElementList[j];
  707.                 text                  = "Title=" + titleAttributeElement.getAttribute("title");
  708.  
  709.                 spanElement.setAttribute("class", "webdeveloper-display-title-attributes");
  710.                 spanElement.setAttribute("title", text);
  711.                 spanElement.appendChild(pageDocument.createTextNode(text));
  712.                 titleAttributeElement.parentNode.insertBefore(spanElement, titleAttributeElement);
  713.             }
  714.         }
  715.     }
  716.  
  717.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/imports/tooltips.css", "webdeveloper-display-title-attributes");
  718.     webdeveloper_toggleFeatureTooltipStyles(element, "webdeveloper-display-title-attributes-tooltips", "span.webdeveloper-display-title-attributes");
  719. }
  720.  
  721. // Displays the topographic information for all elements
  722. function webdeveloper_displayTopographicInformation(element)
  723. {
  724.     webdeveloper_toggleStyleSheet(element, "chrome://webdeveloper/content/stylesheets/display_topographic_information.css", "webdeveloper-display-topographic-information");
  725. }
  726.  
  727. // Formats a CSS color
  728. function webdeveloper_formatColor(color)
  729. {
  730.     var formattedColor = color.toString(16);
  731.  
  732.     // If the formatted color is less than 2 characters long
  733.     if(formattedColor.length < 2)
  734.     {
  735.         return "0" + formattedColor;
  736.     }
  737.     else
  738.     {
  739.         return formattedColor;
  740.     }
  741. }
  742.  
  743. // Returns the depth of the table
  744. function webdeveloper_getTableDepth(table)
  745. {
  746.     var depth = 1;
  747.  
  748.     // If the table is set
  749.     if(table)
  750.     {
  751.         var ancestorList   = webdeveloper_getElementAncestors(table);
  752.         var ancestorLength = ancestorList.length;
  753.         var tagName        = null;
  754.  
  755.         // Loop through the ancestors
  756.         for(var i = 0; i < ancestorLength; i++)
  757.         {
  758.             tagName = ancestorList[i].tagName;
  759.  
  760.             // If the tag name is set and equals table
  761.             if(tagName && tagName.toLowerCase() == "table")
  762.             {
  763.                 depth++;
  764.             }
  765.         }
  766.     }
  767.  
  768.     return depth;
  769. }
  770.  
  771. // Returns the text from a table heading
  772. function webdeveloper_getTableHeadingText(headingNode, headingText)
  773. {
  774.     // If the heading node is set
  775.     if(headingNode)
  776.     {
  777.         var childNode       = null;
  778.         var childNodeList   = headingNode.childNodes;
  779.         var childNodeLength = childNodeList.length;
  780.         var childNodeType   = null;
  781.  
  782.         // Loop through the child nodes
  783.         for(var i = 0; i < childNodeLength; i++)
  784.         {
  785.             childNode     = childNodeList[i];
  786.             childNodeType = childNode.nodeType;
  787.  
  788.             // If the child node type is an element and it does not have a webdeveloper-table-information class
  789.             if(childNodeType == Node.ELEMENT_NODE && (!childNode.hasAttribute("class") || childNode.getAttribute("class") != "webdeveloper-table-information"))
  790.             {
  791.                 headingText = webdeveloper_getTableHeadingText(childNode, headingText);
  792.             }
  793.             else if(childNodeType == Node.TEXT_NODE)
  794.             {
  795.                 headingText += childNode.nodeValue + " ";
  796.             }
  797.         }
  798.     }
  799.  
  800.     return headingText.trim();
  801. }
  802.  
  803. // Outputs the information for a table cell
  804. function webdeveloper_outputTableCellInformation(tableCellElement, pageDocument)
  805. {
  806.     // If the table cell element is set
  807.     if(tableCellElement)
  808.     {
  809.         var divElement   = null;
  810.         var pElement     = null;
  811.         var stringBundle = document.getElementById("webdeveloper-string-bundle");
  812.  
  813.         // If the table cell has a headers attribute
  814.         if(tableCellElement.hasAttribute("headers"))
  815.         {
  816.             var definitionElement = pageDocument.createElement("dd");
  817.             var headerList        = tableCellElement.getAttribute("headers").split(" ");
  818.             var headersLength     = headerList.length;
  819.  
  820.             // Loop through the headers
  821.             for(var i = 0; i < headersLength; i++)
  822.             {
  823.                 pElement = pageDocument.createElement("p");
  824.                 pElement.appendChild(pageDocument.createTextNode(webdeveloper_getTableHeadingText(pageDocument.getElementById(headerList[i]), "")));
  825.                 definitionElement.appendChild(pElement);
  826.             }
  827.  
  828.             // If the definition element has child nodes
  829.             if(definitionElement.childNodes.length > 0)
  830.             {
  831.                 var listElement = pageDocument.createElement("dl");
  832.                 var termElement = pageDocument.createElement("dt");
  833.  
  834.                 divElement = pageDocument.createElement("div");
  835.  
  836.                 termElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_headers")));
  837.                 listElement.appendChild(termElement);
  838.                 listElement.appendChild(definitionElement);
  839.  
  840.                 divElement.setAttribute("class", "webdeveloper-table-information");
  841.                 divElement.appendChild(listElement);
  842.                 tableCellElement.appendChild(divElement);
  843.             }
  844.         }
  845.  
  846.         divElement = pageDocument.createElement("div");
  847.  
  848.         // If the table cell has a scope attribute
  849.         if(tableCellElement.hasAttribute("scope"))
  850.         {
  851.             var scope = tableCellElement.getAttribute("scope");
  852.  
  853.             pElement = pageDocument.createElement("p");
  854.  
  855.             // If the scope is col
  856.             if(scope == "col")
  857.             {
  858.                 pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_tableInformationHeadingColumn")));
  859.             }
  860.             else if(scope == "colgroup")
  861.             {
  862.                 pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_tableInformationHeadingColumnGroup")));
  863.             }
  864.             else if(scope == "row")
  865.             {
  866.                 pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_tableInformationHeadingRow")));
  867.             }
  868.             else if(scope == "rowgroup")
  869.             {
  870.                 pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_tableInformationHeadingRowGroup")));
  871.             }
  872.  
  873.             divElement.appendChild(pElement);
  874.         }
  875.  
  876.         // If the table cell has an abbr attribute
  877.         if(tableCellElement.hasAttribute("abbr"))
  878.         {
  879.             pElement = pageDocument.createElement("p");
  880.             pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_abbreviation") + "=" + tableCellElement.getAttribute("abbr")));
  881.             divElement.appendChild(pElement);
  882.         }
  883.  
  884.         // If the table cell has an axis attribute
  885.         if(tableCellElement.hasAttribute("axis"))
  886.         {
  887.             pElement = pageDocument.createElement("p");
  888.             pElement.appendChild(pageDocument.createTextNode(stringBundle.getString("webdeveloper_axis") + "=" + tableCellElement.getAttribute("axis")));
  889.             divElement.appendChild(pElement);
  890.         }
  891.  
  892.         // If the div element has child nodes
  893.         if(divElement.childNodes.length > 0)
  894.         {
  895.             divElement.setAttribute("class", "webdeveloper-table-information");
  896.             tableCellElement.appendChild(divElement);
  897.         }
  898.     }
  899. }
  900.  
  901. // Sets the image file sizes for a list of images
  902. function webdeveloper_setImageFileSizes(imageList)
  903. {
  904.     var image           = null;
  905.     var imageListLength = imageList.length;
  906.     var newImageList    = new Array();
  907.  
  908.     // Loop through the images
  909.     for(var i = 0; i < imageListLength; i++)
  910.     {
  911.         image          = imageList[i];
  912.         image.fileSize = webdeveloper_getFileSize(image.src);
  913.  
  914.         newImageList.push(image);
  915.     }
  916.  
  917.     return newImageList;
  918. }
  919.  
  920. // Sets the script file sizes for a list of scripts
  921. function webdeveloper_setScriptFileSizes(scriptList)
  922. {
  923.     var script           = null;
  924.     var scriptListLength = scriptList.length;
  925.     var newScriptList    = new Array();
  926.  
  927.     // Loop through the images
  928.     for(var i = 0; i < scriptListLength; i++)
  929.     {
  930.         script                      = scriptList[i];
  931.         script.fileSize             = webdeveloper_getFileSize(script.src);
  932.         script.uncompressedFileSize = webdeveloper_getUncompressedFileSize(script.src);
  933.  
  934.         newScriptList.push(script);
  935.     }
  936.  
  937.     return newScriptList;
  938. }
  939.  
  940. // Sets the style sheet file sizes for a list of style sheets
  941. function webdeveloper_setStyleSheetFileSizes(styleSheetList)
  942. {
  943.     var styleSheet           = null;
  944.     var styleSheetListLength = styleSheetList.length;
  945.     var newStyleSheetList    = new Array();
  946.  
  947.     // Loop through the style sheets
  948.     for(var i = 0; i < styleSheetListLength; i++)
  949.     {
  950.         styleSheet                      = styleSheetList[i];
  951.         styleSheet.fileSize             = webdeveloper_getFileSize(styleSheet.href);
  952.         styleSheet.uncompressedFileSize = webdeveloper_getUncompressedFileSize(styleSheet.href);
  953.  
  954.         newStyleSheetList.push(styleSheet);
  955.     }
  956.  
  957.     return newStyleSheetList;
  958. }
  959.  
  960. // Sorts two anchors
  961. function webdeveloper_sortAnchors(anchorOne, anchorTwo)
  962. {
  963.     // If both anchors are set
  964.     if(anchorOne && anchorTwo)
  965.     {
  966.         var anchorOneLink = null;
  967.         var anchorTwoLink = null;
  968.  
  969.         // If the first anchor has an id attribute
  970.         if(anchorOne.hasAttribute("id"))
  971.         {
  972.             anchorOneLink = anchorOne.getAttribute("id");
  973.         }
  974.         else if(anchorOne.hasAttribute("name"))
  975.         {
  976.             anchorOneLink = anchorOne.getAttribute("name");
  977.         }
  978.  
  979.         // If the second anchor has an id attribute
  980.         if(anchorTwo.hasAttribute("id"))
  981.         {
  982.             anchorTwoLink = anchorTwo.getAttribute("id");
  983.         }
  984.         else if(anchorTwo.hasAttribute("name"))
  985.         {
  986.             anchorTwoLink = anchorTwo.getAttribute("name");
  987.         }
  988.  
  989.         // If the anchor links are equal
  990.         if(anchorOneLink == anchorTwoLink)
  991.         {
  992.             return 0;
  993.         }
  994.         else if(anchorOneLink < anchorTwoLink)
  995.         {
  996.             return -1;
  997.         }
  998.     }
  999.  
  1000.     return 1;
  1001. }
  1002.  
  1003. // Sorts two documents
  1004. function webdeveloper_sortDocuments(documentOne, documentTwo)
  1005. {
  1006.     // If both documents are set
  1007.     if(documentOne && documentTwo)
  1008.     {
  1009.         var documentOneURL = documentOne.documentURI;
  1010.         var documentTwoURL = documentTwo.documentURI;
  1011.  
  1012.         // If the documents are equal
  1013.         if(documentOneURL == documentTwoURL)
  1014.         {
  1015.             return 0;
  1016.         }
  1017.         else if(documentOneURL < documentTwoURL)
  1018.         {
  1019.             return -1;
  1020.         }
  1021.     }
  1022.  
  1023.     return 1;
  1024. }
  1025.  
  1026. // Sorts two documents by file size
  1027. function webdeveloper_sortDocumentsByFileSize(documentOne, documentTwo)
  1028. {
  1029.     // If both documents and their URLs are set
  1030.     if(documentOne && documentTwo && documentOne.documentURI && documentTwo.documentURI)
  1031.     {
  1032.         var documentOneFileSize = webdeveloper_getFileSize(documentOne.documentURI);
  1033.         var documentTwoFileSize = webdeveloper_getFileSize(documentTwo.documentURI);
  1034.  
  1035.         // If the document file sizes are equal
  1036.         if(documentOneFileSize == documentTwoFileSize)
  1037.         {
  1038.             return webdeveloper_sortDocuments(documentOne, documentTwo);
  1039.         }
  1040.         else if(documentOneFileSize > documentTwoFileSize)
  1041.         {
  1042.             return -1;
  1043.         }
  1044.     }
  1045.  
  1046.     return 1;
  1047. }
  1048.  
  1049. // Sorts two images by file size
  1050. function webdeveloper_sortImagesByFileSize(imageOne, imageTwo)
  1051. {
  1052.     // If both images and their file sizes are set
  1053.     if(imageOne && imageTwo && imageOne.fileSize && imageTwo.fileSize)
  1054.     {
  1055.         var imageOneFileSize = imageOne.fileSize;
  1056.         var imageTwoFileSize = imageTwo.fileSize;
  1057.  
  1058.         // If the image file sizes are equal
  1059.         if(imageOneFileSize == imageTwoFileSize)
  1060.         {
  1061.             return webdeveloper_sortImages(imageOne, imageTwo);
  1062.         }
  1063.         else if(imageOneFileSize > imageTwoFileSize)
  1064.         {
  1065.             return -1;
  1066.         }
  1067.     }
  1068.  
  1069.     return 1;
  1070. }
  1071.  
  1072. // Sorts two links
  1073. function webdeveloper_sortLinks(linkOne, linkTwo)
  1074. {
  1075.     // If both links are set
  1076.     if(linkOne && linkTwo)
  1077.     {
  1078.         var linkOneHref = linkOne.href;
  1079.         var linkTwoHref = linkTwo.href;
  1080.  
  1081.         // If the links are equal
  1082.         if(linkOneHref == linkTwoHref)
  1083.         {
  1084.             return 0;
  1085.         }
  1086.         else if(linkOneHref < linkTwoHref)
  1087.         {
  1088.             return -1;
  1089.         }
  1090.     }
  1091.  
  1092.     return 1;
  1093. }
  1094.  
  1095. // Sorts two scripts
  1096. function webdeveloper_sortScripts(scriptOne, scriptTwo)
  1097. {
  1098.     // If both scripts and src are set
  1099.     if(scriptOne && scriptTwo && scriptOne.src && scriptTwo.src)
  1100.     {
  1101.         var scriptOneSrc = scriptOne.src;
  1102.         var scriptTwoSrc = scriptTwo.src;
  1103.  
  1104.         // If the scripts are equal
  1105.         if(scriptOneSrc == scriptTwoSrc)
  1106.         {
  1107.             return 0;
  1108.         }
  1109.         else if(scriptOneSrc < scriptTwoSrc)
  1110.         {
  1111.             return -1;
  1112.         }
  1113.     }
  1114.  
  1115.     return 1;
  1116. }
  1117.  
  1118. // Sorts two scripts by file size
  1119. function webdeveloper_sortScriptsByFileSize(scriptOne, scriptTwo)
  1120. {
  1121.     // If both scripts and src are set
  1122.     if(scriptOne && scriptTwo && scriptOne.src && scriptTwo.src)
  1123.     {
  1124.         var scriptOneFileSize = webdeveloper_getFileSize(scriptOne.src);
  1125.         var scriptTwoFileSize = webdeveloper_getFileSize(scriptTwo.src);
  1126.  
  1127.         // If the script file sizes are equal
  1128.         if(scriptOneFileSize == scriptTwoFileSize)
  1129.         {
  1130.             return webdeveloper_sortScripts(scriptOne, scriptTwo);
  1131.         }
  1132.         else if(scriptOneFileSize > scriptTwoFileSize)
  1133.         {
  1134.             return -1;
  1135.         }
  1136.     }
  1137.  
  1138.     return 1;
  1139. }
  1140.  
  1141. // Sorts two style sheets
  1142. function webdeveloper_sortStyleSheets(styleSheetOne, styleSheetTwo)
  1143. {
  1144.     // If both style sheets and href are set
  1145.     if(styleSheetOne && styleSheetTwo && styleSheetOne.href && styleSheetTwo.href)
  1146.     {
  1147.         var styleSheetOneSrc = styleSheetOne.href;
  1148.         var styleSheetTwoSrc = styleSheetTwo.href;
  1149.  
  1150.         // If the style sheets are equal
  1151.         if(styleSheetOneSrc == styleSheetTwoSrc)
  1152.         {
  1153.             return 0;
  1154.         }
  1155.         else if(styleSheetOneSrc < styleSheetTwoSrc)
  1156.         {
  1157.             return -1;
  1158.         }
  1159.     }
  1160.  
  1161.     return 1;
  1162. }
  1163.  
  1164. // Sorts two style sheets by file size
  1165. function webdeveloper_sortStyleSheetsByFileSize(styleSheetOne, styleSheetTwo)
  1166. {
  1167.     // If both style sheets and href are set
  1168.     if(styleSheetOne && styleSheetTwo && styleSheetOne.href && styleSheetTwo.href)
  1169.     {
  1170.         var styleSheetOneFileSize = webdeveloper_getFileSize(styleSheetOne.href);
  1171.         var styleSheetTwoFileSize = webdeveloper_getFileSize(styleSheetTwo.href);
  1172.  
  1173.         // If the style sheet file sizes are equal
  1174.         if(styleSheetOneFileSize == styleSheetTwoFileSize)
  1175.         {
  1176.             return webdeveloper_sortStyleSheets(styleSheetOne, styleSheetTwo);
  1177.         }
  1178.         else if(styleSheetOneFileSize > styleSheetTwoFileSize)
  1179.         {
  1180.             return -1;
  1181.         }
  1182.     }
  1183.  
  1184.     return 1;
  1185. }
  1186.  
  1187. // Filter for stack level tree walker
  1188. function webdeveloper_stackLevelFilter(node)
  1189. {
  1190.     // If the node has a class attribute and it starts with webdeveloper
  1191.     if(node && (!node.hasAttribute("class") || node.getAttribute("class").indexOf("webdeveloper-") != 0))
  1192.     {
  1193.         var zIndex = node.ownerDocument.defaultView.getComputedStyle(node, null).getPropertyCSSValue("z-index").cssText;
  1194.  
  1195.         // If the node has a z-index and it is not set to auto
  1196.         if(zIndex && zIndex != "auto")
  1197.         {
  1198.             return NodeFilter.FILTER_ACCEPT;
  1199.         }
  1200.     }
  1201.  
  1202.     return NodeFilter.FILTER_SKIP;
  1203. }
  1204.  
  1205. // Tidies a list of anchors by removing duplicates and sorting
  1206. function webdeveloper_tidyAnchors(anchorList)
  1207. {
  1208.     var anchor              = null;
  1209.     var anchorLink          = null;
  1210.     var anchorListLength    = anchorList.length;
  1211.     var newAnchorList       = new Array();
  1212.     var newAnchorListLength = null;
  1213.     var nextAnchor          = null;
  1214.     var nextAnchorLink      = null;
  1215.     var tidiedAnchorList    = new Array();
  1216.  
  1217.     // Loop through the anchors
  1218.     for(var i = 0; i < anchorListLength; i++)
  1219.     {
  1220.         newAnchorList.push(anchorList[i]);
  1221.     }
  1222.  
  1223.     newAnchorList.sort(webdeveloper_sortAnchors);
  1224.  
  1225.     newAnchorListLength = newAnchorList.length;
  1226.  
  1227.     // Loop through the anchors
  1228.     for(i = 0; i < newAnchorListLength; i++)
  1229.     {
  1230.         anchor = newAnchorList[i];
  1231.  
  1232.         // If the anchor has an id attribute
  1233.         if(anchor.hasAttribute("id"))
  1234.         {
  1235.             anchorLink = anchor.getAttribute("id");
  1236.         }
  1237.         else
  1238.         {
  1239.             anchorLink = anchor.getAttribute("name");
  1240.         }
  1241.  
  1242.         // If this is not the last anchor
  1243.         if(i + 1 < newAnchorListLength)
  1244.         {
  1245.             nextAnchor = newAnchorList[i + 1];
  1246.  
  1247.             // If the next anchor has an id attribute
  1248.             if(nextAnchor.hasAttribute("id"))
  1249.             {
  1250.                 nextAnchorLink = nextAnchor.getAttribute("id");
  1251.             }
  1252.             else
  1253.             {
  1254.                 nextAnchorLink = nextAnchor.getAttribute("name");
  1255.             }
  1256.  
  1257.             // If the anchor link is the same as the next anchor link
  1258.             if(anchorLink == nextAnchorLink)
  1259.             {
  1260.                 continue;
  1261.             }
  1262.         }
  1263.  
  1264.         tidiedAnchorList.push(anchor);
  1265.     }
  1266.  
  1267.     return tidiedAnchorList;
  1268. }
  1269.  
  1270. // Tidies a list of colors by removing duplicates and sorting
  1271. function webdeveloper_tidyColors(colorList)
  1272. {
  1273.     var color              = null;
  1274.     var colorListLength    = colorList.length;
  1275.     var newColorList       = new Array();
  1276.     var newColorListLength = null;
  1277.     var tidiedColorList    = new Array();
  1278.  
  1279.     // Loop through the colors
  1280.     for(var i = 0; i < colorListLength; i++)
  1281.     {
  1282.         newColorList.push(colorList[i]);
  1283.     }
  1284.  
  1285.     newColorList.sort();
  1286.  
  1287.     newColorListLength = newColorList.length;
  1288.  
  1289.     // Loop through the colors
  1290.     for(i = 0; i < newColorListLength; i++)
  1291.     {
  1292.         color = newColorList[i];
  1293.  
  1294.         // If this is not the last color and the color is the same as the next color
  1295.         if(i + 1 < newColorListLength && color == newColorList[i + 1])
  1296.         {
  1297.             continue;
  1298.         }
  1299.  
  1300.         tidiedColorList.push(color);
  1301.     }
  1302.  
  1303.     return tidiedColorList;
  1304. }
  1305.  
  1306. // Tidies a list of documents by removing duplicates and sorting
  1307. function webdeveloper_tidyDocuments(documentList)
  1308. {
  1309.     var documentListLength    = documentList.length;
  1310.     var documentURL           = null;
  1311.     var newDocumentList       = new Array();
  1312.     var newDocumentListLength = null;
  1313.     var pageDocument          = null;
  1314.     var tidiedDocumentList    = new Array();
  1315.  
  1316.     // Loop through the documents
  1317.     for(var i = 0; i < documentListLength; i++)
  1318.     {
  1319.         newDocumentList.push(documentList[i]);
  1320.     }
  1321.  
  1322.     newDocumentList.sort(webdeveloper_sortDocuments);
  1323.  
  1324.     newDocumentListLength = newDocumentList.length;
  1325.  
  1326.     // Loop through the documents
  1327.     for(i = 0; i < newDocumentListLength; i++)
  1328.     {
  1329.         pageDocument = newDocumentList[i];
  1330.  
  1331.         // If this is not the last document and the document is the same as the next document
  1332.         if(i + 1 < newDocumentListLength && pageDocument.documentURI == newDocumentList[i + 1].documentURI)
  1333.         {
  1334.             continue;
  1335.         }
  1336.  
  1337.         tidiedDocumentList.push(pageDocument);
  1338.     }
  1339.  
  1340.     return tidiedDocumentList;
  1341. }
  1342.  
  1343. // Tidies a list of links by removing duplicates and sorting
  1344. function webdeveloper_tidyLinks(linkList)
  1345. {
  1346.     var link              = null;
  1347.     var linkListLength    = linkList.length;
  1348.     var newLinkList       = new Array();
  1349.     var newLinkListLength = null;
  1350.     var tidiedLinkList    = new Array();
  1351.  
  1352.     // Loop through the links
  1353.     for(var i = 0; i < linkListLength; i++)
  1354.     {
  1355.         link = linkList[i];
  1356.  
  1357.         // If this link is set
  1358.         if(link.href)
  1359.         {
  1360.             newLinkList.push(link);
  1361.         }
  1362.     }
  1363.  
  1364.     newLinkList.sort(webdeveloper_sortLinks);
  1365.  
  1366.     newLinkListLength = newLinkList.length;
  1367.  
  1368.     // Loop through the links
  1369.     for(i = 0; i < newLinkListLength; i++)
  1370.     {
  1371.         link = newLinkList[i];
  1372.  
  1373.         // If this is not the last link and the link is the same as the next link
  1374.         if(i + 1 < newLinkListLength && link.href == newLinkList[i + 1].href)
  1375.         {
  1376.             continue;
  1377.         }
  1378.  
  1379.         tidiedLinkList.push(link);
  1380.     }
  1381.  
  1382.     return tidiedLinkList;
  1383. }
  1384.  
  1385. // Tidies a list of scripts by removing duplicates and sorting
  1386. function webdeveloper_tidyScripts(scriptList)
  1387. {
  1388.     var script              = null;
  1389.     var scriptListLength    = scriptList.length;
  1390.     var newScriptList       = new Array();
  1391.     var newScriptListLength = null;
  1392.     var tidiedScriptList    = new Array();
  1393.  
  1394.     // Loop through the scripts
  1395.     for(var i = 0; i < scriptListLength; i++)
  1396.     {
  1397.         script = scriptList[i];
  1398.  
  1399.         // If this script and the src is set
  1400.         if(script && script.src)
  1401.         {
  1402.             newScriptList.push(script);
  1403.         }
  1404.     }
  1405.  
  1406.     newScriptList.sort(webdeveloper_sortScripts);
  1407.  
  1408.     newScriptListLength = newScriptList.length;
  1409.  
  1410.     // Loop through the scripts
  1411.     for(i = 0; i < newScriptListLength; i++)
  1412.     {
  1413.         script = newScriptList[i];
  1414.  
  1415.         // If this is not the last script and the script is the same as the next script
  1416.         if(i + 1 < newScriptListLength && script.src == newScriptList[i + 1].src)
  1417.         {
  1418.             continue;
  1419.         }
  1420.  
  1421.         tidiedScriptList.push(script);
  1422.     }
  1423.  
  1424.     return tidiedScriptList;
  1425. }
  1426.  
  1427. // Tidies a list of style sheets by removing duplicates and sorting
  1428. function webdeveloper_tidyStyleSheets(styleSheetList)
  1429. {
  1430.     var styleSheet              = null;
  1431.     var styleSheetListLength    = styleSheetList.length;
  1432.     var newStyleSheetList       = new Array();
  1433.     var newStyleSheetListLength = null;
  1434.     var tidiedStyleSheetList    = new Array();
  1435.  
  1436.     // Loop through the style sheets
  1437.     for(var i = 0; i < styleSheetListLength; i++)
  1438.     {
  1439.         styleSheet = styleSheetList[i];
  1440.  
  1441.         // If this style sheet and the href is set
  1442.         if(styleSheet && styleSheet.href)
  1443.         {
  1444.             newStyleSheetList.push(styleSheet);
  1445.         }
  1446.     }
  1447.  
  1448.     newStyleSheetList.sort(webdeveloper_sortStyleSheets);
  1449.  
  1450.     newStyleSheetListLength = newStyleSheetList.length;
  1451.  
  1452.     // Loop through the style sheets
  1453.     for(i = 0; i < newStyleSheetListLength; i++)
  1454.     {
  1455.         styleSheet = newStyleSheetList[i];
  1456.  
  1457.         // If this is not the last style sheet and the style sheet is the same as the next style sheet
  1458.         if(i + 1 < newStyleSheetListLength && styleSheet.href == newStyleSheetList[i + 1].href)
  1459.         {
  1460.             continue;
  1461.         }
  1462.  
  1463.         tidiedStyleSheetList.push(styleSheet);
  1464.     }
  1465.  
  1466.     return tidiedStyleSheetList;
  1467. }
  1468.  
  1469. // Updates the information menu
  1470. function webdeveloper_updateInformationMenu(suffix)
  1471. {
  1472.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-abbreviations-" + suffix), "checked", "webdeveloper-display-abbreviations");
  1473.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-access-keys-" + suffix), "checked", "webdeveloper-display-access-keys");
  1474.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-anchors-" + suffix), "checked", "webdeveloper-display-anchors");
  1475.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-block-size-" + suffix), "checked", "webdeveloper-display-block-size");
  1476.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-div-order-" + suffix), "checked", "webdeveloper-display-div-order");
  1477.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-element-information-" + suffix), "checked", "webdeveloper-display-element-information");
  1478.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-id-class-details-" + suffix), "checked", "webdeveloper-display-id-class-details");
  1479.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-link-details-" + suffix), "checked", "webdeveloper-display-link-details");
  1480.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-object-information-" + suffix), "checked", "webdeveloper-display-object-information");
  1481.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-stack-levels-" + suffix), "checked", "webdeveloper-display-stack-levels");
  1482.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-tab-index-" + suffix), "checked", "webdeveloper-display-tab-index");
  1483.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-table-depth-" + suffix), "checked", "webdeveloper-display-table-depth");
  1484.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-table-information-" + suffix), "checked", "webdeveloper-display-table-information");
  1485.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-title-attributes-" + suffix), "checked", "webdeveloper-display-title-attributes");
  1486.     webdeveloper_configureElementByAppliedStyle(document.getElementById("webdeveloper-display-topographic-information-" + suffix), "checked", "webdeveloper-display-topographic-information");
  1487. }
  1488.  
  1489. // Displays all the anchors for the page
  1490. function webdeveloper_viewAnchorInformation()
  1491. {
  1492.     var anchor            = null;
  1493.     var anchorLength      = null;
  1494.     var anchorLink        = null;
  1495.     var anchorList        = null;
  1496.     var divElement        = null;
  1497.     var documentList      = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  1498.     var documentLength    = documentList.length;
  1499.     var documentURL       = null;
  1500.     var linkElement       = null;
  1501.     var linkHref          = null;
  1502.     var linkLength        = null;
  1503.     var listElement       = null;
  1504.     var listItemElement   = null;
  1505.     var oldTab            = getBrowser().selectedTab;
  1506.     var oldURL            = getBrowser().currentURI.spec;
  1507.     var generatedDocument = webdeveloper_generateDocument("");
  1508.     var bodyElement       = webdeveloper_getDocumentBodyElement(generatedDocument);
  1509.     var headElement       = webdeveloper_getDocumentHeadElement(generatedDocument);
  1510.     var headerElement     = generatedDocument.createElement("h1");
  1511.     var pageDocument      = null;
  1512.     var pElement          = null;
  1513.     var scriptElement     = generatedDocument.createElement("script");
  1514.     var spanElement       = null;
  1515.     var stringBundle      = document.getElementById("webdeveloper-string-bundle");
  1516.     var title             = stringBundle.getFormattedString("webdeveloper_viewAnchorInformationTitle", [oldURL]);
  1517.  
  1518.     generatedDocument.title = title;
  1519.  
  1520.     webdeveloper_addGeneratedStyles(generatedDocument);
  1521.  
  1522.     headerElement.appendChild(generatedDocument.createTextNode(title));
  1523.     bodyElement.appendChild(headerElement);
  1524.  
  1525.     webdeveloper_addGeneratedTools(generatedDocument);
  1526.  
  1527.     // Loop through the documents
  1528.     for(var i = 0; i < documentLength; i++)
  1529.     {
  1530.         divElement    = generatedDocument.createElement("div");
  1531.         headerElement = generatedDocument.createElement("h2");
  1532.         linkElement   = generatedDocument.createElement("a");
  1533.         pageDocument  = documentList[i];
  1534.         anchorList    = webdeveloper_evaluateXPath(pageDocument, "//*[@id] | //a[@name]");
  1535.         documentURL   = pageDocument.documentURI;
  1536.         spanElement   = generatedDocument.createElement("span");
  1537.  
  1538.         // If the tidy information preference is set
  1539.         if(webdeveloper_getBooleanPreference("webdeveloper.information.tidy", true))
  1540.         {
  1541.             anchorList = webdeveloper_tidyAnchors(anchorList);
  1542.         }
  1543.  
  1544.         spanElement.setAttribute("class", "expanded pivot");
  1545.         headerElement.appendChild(spanElement);
  1546.         linkElement.setAttribute("href", documentURL);
  1547.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  1548.         headerElement.appendChild(linkElement);
  1549.         bodyElement.appendChild(headerElement);
  1550.  
  1551.         anchorLength = anchorList.length;
  1552.  
  1553.         // If there are no anchors
  1554.         if(anchorLength == 0)
  1555.         {
  1556.             pElement = generatedDocument.createElement("p");
  1557.  
  1558.             pElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_noAnchors")));
  1559.             divElement.appendChild(pElement);
  1560.         }
  1561.         else
  1562.         {
  1563.             listElement = generatedDocument.createElement("ol");
  1564.  
  1565.             // Loop through the links
  1566.             for(var j = 0; j < anchorLength; j++)
  1567.             {
  1568.                 anchor = anchorList[j];
  1569.  
  1570.                 // If the anchor has an id attribute
  1571.                 if(anchor.hasAttribute("id"))
  1572.                 {
  1573.                     anchorLink = "#" + anchor.getAttribute("id");
  1574.                 }
  1575.                 else
  1576.                 {
  1577.                     anchorLink = "#" + anchor.getAttribute("name");
  1578.                 }
  1579.  
  1580.                 linkElement     = generatedDocument.createElement("a");
  1581.                 listItemElement = generatedDocument.createElement("li");
  1582.  
  1583.                 linkElement.setAttribute("href", documentURL + anchorLink);
  1584.                 linkElement.appendChild(generatedDocument.createTextNode(anchorLink));
  1585.                 listItemElement.appendChild(linkElement);
  1586.                 listElement.appendChild(listItemElement);
  1587.             }
  1588.  
  1589.             divElement.appendChild(listElement);
  1590.         }
  1591.  
  1592.         divElement.setAttribute("class", "output");
  1593.         bodyElement.appendChild(divElement);
  1594.     }
  1595.  
  1596.     scriptElement.setAttribute("defer", "defer");
  1597.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  1598.     scriptElement.setAttribute("type", "text/javascript");
  1599.     headElement.appendChild(scriptElement);
  1600.  
  1601.     scriptElement = generatedDocument.createElement("script");
  1602.  
  1603.     scriptElement.setAttribute("defer", "defer");
  1604.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  1605.     scriptElement.setAttribute("type", "text/javascript");
  1606.     headElement.appendChild(scriptElement);
  1607.  
  1608.     // If the open tabs in background preference is set to true
  1609.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  1610.     {
  1611.         getBrowser().selectedTab = oldTab;
  1612.     }
  1613. }
  1614.  
  1615. // Displays all the colors on the page
  1616. function webdeveloper_viewColorInformation()
  1617. {
  1618.     var color                 = null;
  1619.     var colorList             = null;
  1620.     var colorsLength          = null;
  1621.     var definitionElement     = null;
  1622.     var definitionListElement = null;
  1623.     var divElement            = null;
  1624.     var documentList          = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  1625.     var documentLength        = documentList.length;
  1626.     var documentURL           = null;
  1627.     var element               = null;
  1628.     var oldTab                = getBrowser().selectedTab;
  1629.     var oldURL                = getBrowser().currentURI.spec;
  1630.     var generatedDocument     = webdeveloper_generateDocument("");
  1631.     var bodyElement           = webdeveloper_getDocumentBodyElement(generatedDocument);
  1632.     var headElement           = webdeveloper_getDocumentHeadElement(generatedDocument);
  1633.     var headerElement         = generatedDocument.createElement("h1");
  1634.     var linkElement           = generatedDocument.createElement("link");
  1635.     var pageDocument          = null;
  1636.     var scriptElement         = generatedDocument.createElement("script");
  1637.     var spanElement           = null;
  1638.     var termElement           = null;
  1639.     var title                 = document.getElementById("webdeveloper-string-bundle").getFormattedString("webdeveloper_viewColorInformationTitle", [oldURL]);
  1640.     var treeWalker            = null;
  1641.  
  1642.     generatedDocument.title = title;
  1643.  
  1644.     webdeveloper_addGeneratedStyles(generatedDocument);
  1645.  
  1646.     linkElement.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated/view_color_information.css");
  1647.     linkElement.setAttribute("rel", "stylesheet");
  1648.     linkElement.setAttribute("type", "text/css");
  1649.     headElement.appendChild(linkElement);
  1650.  
  1651.     headerElement.appendChild(generatedDocument.createTextNode(title));
  1652.     bodyElement.appendChild(headerElement);
  1653.  
  1654.     webdeveloper_addGeneratedTools(generatedDocument);
  1655.  
  1656.     // Loop through the documents
  1657.     for(var i = 0; i < documentLength; i++)
  1658.     {
  1659.         colorList     = new Array();
  1660.         divElement    = generatedDocument.createElement("div");
  1661.         headerElement = generatedDocument.createElement("h2");
  1662.         linkElement   = generatedDocument.createElement("a");
  1663.         pageDocument  = documentList[i];
  1664.         documentURL   = pageDocument.documentURI;
  1665.         spanElement   = generatedDocument.createElement("span");
  1666.         treeWalker    = pageDocument.createTreeWalker(webdeveloper_getDocumentBodyElement(pageDocument), NodeFilter.SHOW_ELEMENT, null, false);
  1667.  
  1668.         // Loop through the anchor elements
  1669.         while((element = treeWalker.nextNode()) != null)
  1670.         {
  1671.             webdeveloper_addColor(element, "background-color", colorList);
  1672.             webdeveloper_addColor(element, "border-bottom-color", colorList);
  1673.             webdeveloper_addColor(element, "border-left-color", colorList);
  1674.             webdeveloper_addColor(element, "border-right-color", colorList);
  1675.             webdeveloper_addColor(element, "border-top-color", colorList);
  1676.             webdeveloper_addColor(element, "color", colorList);
  1677.         }
  1678.  
  1679.         spanElement.setAttribute("class", "expanded pivot");
  1680.         headerElement.appendChild(spanElement);
  1681.         linkElement.setAttribute("href", documentURL);
  1682.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  1683.         headerElement.appendChild(linkElement);
  1684.         bodyElement.appendChild(headerElement);
  1685.  
  1686.         colorList    = webdeveloper_tidyColors(colorList);
  1687.         colorsLength = colorList.length;
  1688.  
  1689.         // Loop through the colors
  1690.         for(var j = 0; j < colorsLength; j++)
  1691.         {
  1692.             color                 = colorList[j];
  1693.             definitionElement     = generatedDocument.createElement("dd");
  1694.             definitionListElement = generatedDocument.createElement("dl");
  1695.             termElement           = generatedDocument.createElement("dt");
  1696.  
  1697.             termElement.appendChild(generatedDocument.createTextNode(color));
  1698.             definitionListElement.appendChild(termElement);
  1699.  
  1700.             definitionElement.setAttribute("style", "background-color: " + color);
  1701.             definitionListElement.appendChild(definitionElement);
  1702.             divElement.appendChild(definitionListElement);
  1703.         }
  1704.  
  1705.         divElement.setAttribute("class", "output");
  1706.         bodyElement.appendChild(divElement);
  1707.     }
  1708.  
  1709.     scriptElement.setAttribute("defer", "defer");
  1710.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  1711.     scriptElement.setAttribute("type", "text/javascript");
  1712.     headElement.appendChild(scriptElement);
  1713.  
  1714.     scriptElement = generatedDocument.createElement("script");
  1715.  
  1716.     scriptElement.setAttribute("defer", "defer");
  1717.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  1718.     scriptElement.setAttribute("type", "text/javascript");
  1719.     headElement.appendChild(scriptElement);
  1720.  
  1721.     // If the open tabs in background preference is set to true
  1722.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  1723.     {
  1724.         getBrowser().selectedTab = oldTab;
  1725.     }
  1726. }
  1727.  
  1728. // Displays an outline of the page
  1729. function webdeveloper_viewDocumentOutline()
  1730. {
  1731.     var divElement           = null;
  1732.     var documentList         = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  1733.     var documentLength       = documentList.length;
  1734.     var documentURL          = null;
  1735.     var headerElementList    = null;
  1736.     var headerElementsLength = null;
  1737.     var headerImageList      = null;
  1738.     var headerImagesLength   = null;
  1739.     var headerLevel          = null;
  1740.     var headerTagName        = null;
  1741.     var headerText           = null;
  1742.     var oldTab               = getBrowser().selectedTab;
  1743.     var oldURL               = getBrowser().currentURI.spec;
  1744.     var generatedDocument    = webdeveloper_generateDocument("");
  1745.     var bodyElement          = webdeveloper_getDocumentBodyElement(generatedDocument);
  1746.     var headElement          = webdeveloper_getDocumentHeadElement(generatedDocument);
  1747.     var headerElement        = generatedDocument.createElement("h1");
  1748.     var linkElement          = generatedDocument.createElement("link");
  1749.     var outlineElement       = null;
  1750.     var pageDocument         = null;
  1751.     var previousHeaderLevel  = null;
  1752.     var scriptElement        = generatedDocument.createElement("script");
  1753.     var spanElement          = null;
  1754.     var stringBundle         = document.getElementById("webdeveloper-string-bundle");
  1755.     var title                = stringBundle.getFormattedString("webdeveloper_viewDocumentOutlineTitle", [oldURL]);
  1756.     var treeWalker           = null;
  1757.  
  1758.     generatedDocument.title = title;
  1759.  
  1760.     webdeveloper_addGeneratedStyles(generatedDocument);
  1761.  
  1762.     linkElement.setAttribute("href", "chrome://webdeveloper/content/stylesheets/generated/view_document_outline.css");
  1763.     linkElement.setAttribute("rel", "stylesheet");
  1764.     linkElement.setAttribute("type", "text/css");
  1765.     headElement.appendChild(linkElement);
  1766.  
  1767.     headerElement.appendChild(generatedDocument.createTextNode(title));
  1768.     bodyElement.appendChild(headerElement);
  1769.  
  1770.     webdeveloper_addGeneratedTools(generatedDocument);
  1771.  
  1772.     // Loop through the documents
  1773.     for(var i = 0; i < documentLength; i++)
  1774.     {
  1775.         divElement           = generatedDocument.createElement("div");
  1776.         headerElement        = generatedDocument.createElement("h2");
  1777.         linkElement          = generatedDocument.createElement("a");
  1778.         pageDocument         = documentList[i];
  1779.         documentURL          = pageDocument.documentURI;
  1780.         headerElementList    = webdeveloper_evaluateXPath(pageDocument, "//h1 | //h2 | //h3 | //h4 | //h5 | //h6");
  1781.         headerElementsLength = headerElementList.length;
  1782.         previousHeaderLevel  = 0;
  1783.         spanElement          = generatedDocument.createElement("span");
  1784.  
  1785.         spanElement.setAttribute("class", "expanded pivot");
  1786.         headerElement.appendChild(spanElement);
  1787.         linkElement.setAttribute("href", documentURL);
  1788.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  1789.         headerElement.appendChild(linkElement);
  1790.         bodyElement.appendChild(headerElement);
  1791.  
  1792.         // Loop through the heading elements
  1793.         for(var j = 0; j < headerElementsLength; j++)
  1794.         {
  1795.             headerElement = headerElementList[j];
  1796.             headerTagName = headerElement.tagName.toLowerCase();
  1797.             headerText    = webdeveloper_getElementText(headerElement).trim();
  1798.             headerLevel   = parseInt(headerTagName.substring(1));
  1799.  
  1800.             // Loop through any missing headers
  1801.             for(var k = previousHeaderLevel + 1; k < headerLevel; k++)
  1802.             {
  1803.                 outlineElement = generatedDocument.createElement("h" + k);
  1804.  
  1805.                 outlineElement.setAttribute("class", "webdeveloper-document-outline webdeveloper-document-outline-missing");
  1806.                 outlineElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_viewDocumentOutlineMissingHeading")));
  1807.                 divElement.appendChild(outlineElement);
  1808.             }
  1809.  
  1810.             // If there is no header text
  1811.             if(!headerText)
  1812.             {
  1813.                 headerImageList    = webdeveloper_evaluateXPath(headerElement, "img[@alt]");
  1814.                 headerImagesLength = headerImageList.length;
  1815.                 headerText         = "";
  1816.  
  1817.                 // Loop through the heading images
  1818.                 for(var k = 0; k < headerImagesLength; k++)
  1819.                 {
  1820.                     headerText += headerImageList[k].getAttribute("alt") + " ";
  1821.                 }
  1822.            
  1823.                    headerText = headerText.trim();
  1824.            
  1825.                 // If there is now header text
  1826.                 if(headerText)
  1827.                 {
  1828.                     headerText = "[" + headerText + "]";
  1829.                 }
  1830.                 else
  1831.                 {
  1832.                     headerText = stringBundle.getString("webdeveloper_viewDocumentOutlineEmptyHeading");
  1833.                 }
  1834.             }
  1835.  
  1836.             outlineElement = generatedDocument.createElement(headerTagName);
  1837.  
  1838.             outlineElement.setAttribute("class", "webdeveloper-document-outline");
  1839.             outlineElement.appendChild(generatedDocument.createTextNode(headerText));
  1840.             divElement.appendChild(outlineElement);
  1841.  
  1842.             previousHeaderLevel = headerLevel;
  1843.         }
  1844.  
  1845.         divElement.setAttribute("class", "output");
  1846.         bodyElement.appendChild(divElement);
  1847.     }
  1848.  
  1849.     scriptElement.setAttribute("defer", "defer");
  1850.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  1851.     scriptElement.setAttribute("type", "text/javascript");
  1852.     headElement.appendChild(scriptElement);
  1853.  
  1854.     scriptElement = generatedDocument.createElement("script");
  1855.  
  1856.     scriptElement.setAttribute("defer", "defer");
  1857.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  1858.     scriptElement.setAttribute("type", "text/javascript");
  1859.     headElement.appendChild(scriptElement);
  1860.  
  1861.     // If the open tabs in background preference is set to true
  1862.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  1863.     {
  1864.         getBrowser().selectedTab = oldTab;
  1865.     }
  1866. }
  1867.  
  1868. // View JavaScript
  1869. function webdeveloper_viewJavaScript()
  1870. {
  1871.     var divElement        = null;
  1872.     var documentList      = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  1873.     var documentLength    = documentList.length;
  1874.     var documentURL       = null;
  1875.     var linkElement       = null;
  1876.     var oldTab            = getBrowser().selectedTab;
  1877.     var oldURL            = getBrowser().currentURI.spec;
  1878.     var generatedDocument = webdeveloper_generateDocument("");
  1879.     var bodyElement       = webdeveloper_getDocumentBodyElement(generatedDocument);
  1880.     var headElement       = webdeveloper_getDocumentHeadElement(generatedDocument);
  1881.     var headerElement     = generatedDocument.createElement("h1");
  1882.     var pageDocument      = null;
  1883.     var preElement        = null;
  1884.     var scriptElement     = null;
  1885.     var scriptLength      = null;
  1886.     var scriptList        = new Array();
  1887.     var scriptSource      = null;
  1888.     var spanElement       = null;
  1889.     var stringBundle      = document.getElementById("webdeveloper-string-bundle");
  1890.     var title             = stringBundle.getFormattedString("webdeveloper_viewJavaScriptTitle", [oldURL]);
  1891.  
  1892.     generatedDocument.title = title;
  1893.  
  1894.     webdeveloper_addGeneratedStyles(generatedDocument);
  1895.  
  1896.     headerElement.appendChild(generatedDocument.createTextNode(title));
  1897.     bodyElement.appendChild(headerElement);
  1898.  
  1899.     webdeveloper_addGeneratedTools(generatedDocument);
  1900.  
  1901.     // Loop through the documents
  1902.     for(var i = 0; i < documentLength; i++)
  1903.     {
  1904.         headerElement = generatedDocument.createElement("h2");
  1905.         linkElement   = generatedDocument.createElement("a");
  1906.         pageDocument  = documentList[i];
  1907.         documentURL   = pageDocument.documentURI;
  1908.         scriptList    = pageDocument.getElementsByTagName("script");
  1909.         scriptLength  = scriptList.length;
  1910.  
  1911.         linkElement.setAttribute("href", pageDocument.documentURI);
  1912.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  1913.         headerElement.appendChild(linkElement);
  1914.         bodyElement.appendChild(headerElement);
  1915.  
  1916.         // Loop through the scripts
  1917.         for(var j = 0; j < scriptLength; j++)
  1918.         {
  1919.             divElement    = generatedDocument.createElement("div");
  1920.             headerElement = generatedDocument.createElement("h3");
  1921.             preElement    = generatedDocument.createElement("pre");
  1922.             scriptElement = scriptList[j];
  1923.             scriptSource  = scriptElement.src;
  1924.             spanElement   = generatedDocument.createElement("span");
  1925.  
  1926.             // If the script is external
  1927.             if(scriptSource)
  1928.             {
  1929.                 // If this is a not chrome script
  1930.                 if(scriptSource.indexOf("chrome://") != 0)
  1931.                 {
  1932.                     linkElement = generatedDocument.createElement("a");
  1933.  
  1934.                     spanElement.setAttribute("class", "expanded pivot");
  1935.                     headerElement.appendChild(spanElement);
  1936.                     linkElement.setAttribute("href", scriptSource);
  1937.                     linkElement.appendChild(generatedDocument.createTextNode(scriptSource));
  1938.                     headerElement.appendChild(linkElement);
  1939.                     bodyElement.appendChild(headerElement);
  1940.  
  1941.                     preElement.appendChild(generatedDocument.createTextNode(webdeveloper_retrieveSource(scriptSource).replace(new RegExp("\r", "gi"), "\n")));
  1942.                     divElement.setAttribute("class", "output");
  1943.                     divElement.appendChild(preElement);
  1944.                     bodyElement.appendChild(divElement);
  1945.                 }
  1946.             }
  1947.             else
  1948.             {
  1949.                 spanElement.setAttribute("class", "expanded pivot");
  1950.                 headerElement.appendChild(spanElement);
  1951.                 headerElement.appendChild(generatedDocument.createTextNode(stringBundle.getFormattedString("webdeveloper_inlineScript", [documentURL])));
  1952.                 bodyElement.appendChild(headerElement);
  1953.  
  1954.                 preElement.appendChild(generatedDocument.createTextNode(scriptElement.innerHTML));
  1955.                 divElement.setAttribute("class", "output");
  1956.                 divElement.appendChild(preElement);
  1957.                 bodyElement.appendChild(divElement);
  1958.             }
  1959.         }
  1960.     }
  1961.  
  1962.     scriptElement = generatedDocument.createElement("script");
  1963.  
  1964.     scriptElement.setAttribute("defer", "defer");
  1965.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  1966.     scriptElement.setAttribute("type", "text/javascript");
  1967.     headElement.appendChild(scriptElement);
  1968.  
  1969.     scriptElement = generatedDocument.createElement("script");
  1970.  
  1971.     scriptElement.setAttribute("defer", "defer");
  1972.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  1973.     scriptElement.setAttribute("type", "text/javascript");
  1974.     headElement.appendChild(scriptElement);
  1975.  
  1976.     // If the open tabs in background preference is set to true
  1977.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  1978.     {
  1979.         getBrowser().selectedTab = oldTab;
  1980.     }
  1981. }
  1982.  
  1983. // Displays all the links for the page
  1984. function webdeveloper_viewLinkInformation()
  1985. {
  1986.     var divElement        = null;
  1987.     var documentList      = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  1988.     var documentLength    = documentList.length;
  1989.     var documentURL       = null;
  1990.     var link              = null;
  1991.     var linkElement       = null;
  1992.     var linkHref          = null;
  1993.     var linkLength        = null;
  1994.     var links             = null;
  1995.     var listElement       = null;
  1996.     var listItemElement   = null;
  1997.     var oldTab            = getBrowser().selectedTab;
  1998.     var oldURL            = getBrowser().currentURI.spec;
  1999.     var generatedDocument = webdeveloper_generateDocument("");
  2000.     var bodyElement       = webdeveloper_getDocumentBodyElement(generatedDocument);
  2001.     var headElement       = webdeveloper_getDocumentHeadElement(generatedDocument);
  2002.     var headerElement     = generatedDocument.createElement("h1");
  2003.     var pageDocument      = null;
  2004.     var pElement          = null;
  2005.     var scriptElement     = generatedDocument.createElement("script");
  2006.     var spanElement       = null;
  2007.     var stringBundle      = document.getElementById("webdeveloper-string-bundle");
  2008.     var title             = stringBundle.getFormattedString("webdeveloper_viewLinkInformationTitle", [oldURL]);
  2009.  
  2010.     generatedDocument.title = title;
  2011.  
  2012.     webdeveloper_addGeneratedStyles(generatedDocument);
  2013.  
  2014.     headerElement.appendChild(generatedDocument.createTextNode(title));
  2015.     bodyElement.appendChild(headerElement);
  2016.  
  2017.     webdeveloper_addGeneratedTools(generatedDocument);
  2018.  
  2019.     // Loop through the documents
  2020.     for(var i = 0; i < documentLength; i++)
  2021.     {
  2022.         divElement    = generatedDocument.createElement("div");
  2023.         headerElement = generatedDocument.createElement("h2");
  2024.         linkElement   = generatedDocument.createElement("a");
  2025.         pageDocument  = documentList[i];
  2026.         documentURL   = pageDocument.documentURI;
  2027.         links         = pageDocument.links;
  2028.         spanElement   = generatedDocument.createElement("span");
  2029.  
  2030.         // If the tidy information preference is set
  2031.         if(webdeveloper_getBooleanPreference("webdeveloper.information.tidy", true))
  2032.         {
  2033.             links = webdeveloper_tidyLinks(links);
  2034.         }
  2035.  
  2036.         spanElement.setAttribute("class", "expanded pivot");
  2037.         headerElement.appendChild(spanElement);
  2038.         linkElement.setAttribute("href", documentURL);
  2039.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  2040.         headerElement.appendChild(linkElement);
  2041.         bodyElement.appendChild(headerElement);
  2042.  
  2043.         linkLength = links.length;
  2044.  
  2045.         // If there are no links
  2046.         if(linkLength == 0)
  2047.         {
  2048.             pElement = generatedDocument.createElement("p");
  2049.  
  2050.             pElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_noLinks")));
  2051.             divElement.appendChild(pElement);
  2052.         }
  2053.         else
  2054.         {
  2055.             listElement = generatedDocument.createElement("ol");
  2056.  
  2057.             // Loop through the links
  2058.             for(var j = 0; j < linkLength; j++)
  2059.             {
  2060.                 link     = links[j];
  2061.                 linkHref = link.href;
  2062.  
  2063.                 // If the link is set
  2064.                 if(linkHref)
  2065.                 {
  2066.                     linkElement     = generatedDocument.createElement("a");
  2067.                     listItemElement = generatedDocument.createElement("li");
  2068.  
  2069.                     linkElement.setAttribute("href", linkHref);
  2070.                     linkElement.appendChild(generatedDocument.createTextNode(linkHref));
  2071.                     listItemElement.appendChild(linkElement);
  2072.                     listElement.appendChild(listItemElement);
  2073.                 }
  2074.             }
  2075.  
  2076.             divElement.appendChild(listElement);
  2077.         }
  2078.  
  2079.         divElement.setAttribute("class", "output");
  2080.         bodyElement.appendChild(divElement);
  2081.     }
  2082.  
  2083.     scriptElement.setAttribute("defer", "defer");
  2084.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  2085.     scriptElement.setAttribute("type", "text/javascript");
  2086.     headElement.appendChild(scriptElement);
  2087.  
  2088.     scriptElement = generatedDocument.createElement("script");
  2089.  
  2090.     scriptElement.setAttribute("defer", "defer");
  2091.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  2092.     scriptElement.setAttribute("type", "text/javascript");
  2093.     headElement.appendChild(scriptElement);
  2094.  
  2095.     // If the open tabs in background preference is set to true
  2096.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  2097.     {
  2098.         getBrowser().selectedTab = oldTab;
  2099.     }
  2100. }
  2101.  
  2102. // Displays all the meta tags for the page
  2103. function webdeveloper_viewMetaTagInformation()
  2104. {
  2105.     var cellDataElement   = null;
  2106.     var cellHeaderElement = null;
  2107.     var divElement        = null;
  2108.     var documentList      = webdeveloper_getDocuments(webdeveloper_getContentWindow());
  2109.     var documentLength    = documentList.length;
  2110.     var documentURL       = null;
  2111.     var linkElement       = null;
  2112.     var metaTag           = null;
  2113.     var metaTags          = null;
  2114.     var metaTagsLength    = null;
  2115.     var oldTab            = getBrowser().selectedTab;
  2116.     var oldURL            = getBrowser().currentURI.spec;
  2117.     var generatedDocument = webdeveloper_generateDocument("");
  2118.     var bodyElement       = webdeveloper_getDocumentBodyElement(generatedDocument);
  2119.     var headElement       = webdeveloper_getDocumentHeadElement(generatedDocument);
  2120.     var headerElement     = generatedDocument.createElement("h1");
  2121.     var pageDocument      = null;
  2122.     var pElement          = null;
  2123.     var scriptElement     = generatedDocument.createElement("script");
  2124.     var spanElement       = null;
  2125.     var stringBundle      = document.getElementById("webdeveloper-string-bundle");
  2126.     var tableElement      = null;
  2127.     var tableRowElement   = null;
  2128.     var title             = stringBundle.getFormattedString("webdeveloper_viewMetaTagInformationTitle", [oldURL]);
  2129.  
  2130.     generatedDocument.title = title;
  2131.  
  2132.     webdeveloper_addGeneratedStyles(generatedDocument);
  2133.  
  2134.     headerElement.appendChild(generatedDocument.createTextNode(title));
  2135.     bodyElement.appendChild(headerElement);
  2136.  
  2137.     webdeveloper_addGeneratedTools(generatedDocument);
  2138.  
  2139.     // Loop through the documents
  2140.     for(var i = 0; i < documentLength; i++)
  2141.     {
  2142.         divElement     = generatedDocument.createElement("div");
  2143.         headerElement  = generatedDocument.createElement("h2");
  2144.         linkElement    = generatedDocument.createElement("a");
  2145.         pageDocument   = documentList[i];
  2146.         documentURL    = pageDocument.documentURI;
  2147.         metaTags       = pageDocument.getElementsByTagName("meta");
  2148.         metaTagsLength = metaTags.length;
  2149.         spanElement    = generatedDocument.createElement("span");
  2150.  
  2151.         spanElement.setAttribute("class", "expanded pivot");
  2152.         headerElement.appendChild(spanElement);
  2153.         linkElement.setAttribute("href", documentURL);
  2154.         linkElement.appendChild(generatedDocument.createTextNode(documentURL));
  2155.         headerElement.appendChild(linkElement);
  2156.         bodyElement.appendChild(headerElement);
  2157.  
  2158.         // If there are no meta tags
  2159.         if(metaTagsLength == 0)
  2160.         {
  2161.             pElement = generatedDocument.createElement("p");
  2162.  
  2163.             pElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_noMetaTags")));
  2164.             divElement.appendChild(pElement);
  2165.         }
  2166.         else
  2167.         {
  2168.             tableElement    = generatedDocument.createElement("table");
  2169.             tableRowElement = generatedDocument.createElement("tr");
  2170.  
  2171.             //  Name heading
  2172.             cellHeaderElement = generatedDocument.createElement("th");
  2173.  
  2174.             cellHeaderElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_name")));
  2175.             tableRowElement.appendChild(cellHeaderElement);
  2176.  
  2177.             //  Content heading
  2178.             cellHeaderElement = generatedDocument.createElement("th");
  2179.  
  2180.             cellHeaderElement.appendChild(generatedDocument.createTextNode(stringBundle.getString("webdeveloper_content")));
  2181.             tableRowElement.appendChild(cellHeaderElement);
  2182.             tableElement.appendChild(tableRowElement);
  2183.  
  2184.             // Loop through the meta tags
  2185.             for(var j = 0; j < metaTagsLength; j++)
  2186.             {
  2187.                 metaTag         = metaTags[j];
  2188.                 tableRowElement = generatedDocument.createElement("tr");
  2189.  
  2190.                 // If this is an even row
  2191.                 if(j % 2 != 0)
  2192.                 {
  2193.                     tableRowElement.setAttribute("class", "shaded");
  2194.                 }
  2195.  
  2196.                 cellDataElement = generatedDocument.createElement("td");
  2197.  
  2198.                 // If the meta tag has a name attribute
  2199.                 if(metaTag.hasAttribute("name"))
  2200.                 {
  2201.                     cellDataElement.appendChild(generatedDocument.createTextNode(metaTag.getAttribute("name")));
  2202.                 }
  2203.                 else if(metaTag.hasAttribute("http-equiv"))
  2204.                 {
  2205.                     cellDataElement.appendChild(generatedDocument.createTextNode(metaTag.getAttribute("http-equiv")));
  2206.                 }
  2207.  
  2208.                 tableRowElement.appendChild(cellDataElement);
  2209.  
  2210.                 //  Content
  2211.                 cellDataElement = generatedDocument.createElement("td");
  2212.  
  2213.                 cellDataElement.appendChild(generatedDocument.createTextNode(metaTag.getAttribute("content")));
  2214.                 tableRowElement.appendChild(cellDataElement);
  2215.                 tableElement.appendChild(tableRowElement);
  2216.             }
  2217.  
  2218.             tableElement.setAttribute("class", "sortable");
  2219.             divElement.appendChild(tableElement);
  2220.         }
  2221.  
  2222.         divElement.setAttribute("class", "output");
  2223.         bodyElement.appendChild(divElement);
  2224.     }
  2225.  
  2226.     scriptElement.setAttribute("defer", "defer");
  2227.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/dom.js");
  2228.     scriptElement.setAttribute("type", "text/javascript");
  2229.     headElement.appendChild(scriptElement);
  2230.  
  2231.     scriptElement = generatedDocument.createElement("script");
  2232.  
  2233.     scriptElement.setAttribute("defer", "defer");
  2234.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/common/xpath.js");
  2235.     scriptElement.setAttribute("type", "text/javascript");
  2236.     headElement.appendChild(scriptElement);
  2237.  
  2238.     scriptElement = generatedDocument.createElement("script");
  2239.  
  2240.     scriptElement.setAttribute("defer", "defer");
  2241.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/output_pivot.js");
  2242.     scriptElement.setAttribute("type", "text/javascript");
  2243.     headElement.appendChild(scriptElement);
  2244.  
  2245.     scriptElement = generatedDocument.createElement("script");
  2246.  
  2247.     scriptElement.setAttribute("defer", "defer");
  2248.     scriptElement.setAttribute("src", "chrome://webdeveloper/content/generated/table_sort.js");
  2249.     scriptElement.setAttribute("type", "text/javascript");
  2250.     headElement.appendChild(scriptElement);
  2251.  
  2252.     // If the open tabs in background preference is set to true
  2253.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  2254.     {
  2255.         getBrowser().selectedTab = oldTab;
  2256.     }
  2257. }
  2258.  
  2259. // View page information
  2260. function webdeveloper_viewPageInformation(chromeLocation)
  2261. {
  2262.     // Try to use the built-in browser function
  2263.     try
  2264.     {
  2265.         BrowserPageInfo(null);
  2266.     }
  2267.     catch(exception)
  2268.     {
  2269.         window.openDialog(chromeLocation, "webdeveloper-page-information-dialog", "chrome,dialog=no,resizable");
  2270.     }
  2271. }
  2272.  
  2273. // View the response headers
  2274. function webdeveloper_viewResponseHeaders()
  2275. {
  2276.     var headerElement     = null;
  2277.     var oldTab            = getBrowser().selectedTab;
  2278.     var oldURL            = getBrowser().currentURI.spec;
  2279.     var generatedDocument = webdeveloper_generateDocument("");
  2280.     var bodyElement       = webdeveloper_getDocumentBodyElement(generatedDocument);
  2281.     var preElement        = null;
  2282.     var request           = new XMLHttpRequest();
  2283.     var responseHeaders   = null;
  2284.     var title             = document.getElementById("webdeveloper-string-bundle").getFormattedString("webdeveloper_viewResponseHeadersTitle", [oldURL]);
  2285.  
  2286.     request.open("get", oldURL, false);
  2287.     request.send(null);
  2288.  
  2289.     responseHeaders         = request.getAllResponseHeaders();
  2290.     generatedDocument.title = title;
  2291.  
  2292.     webdeveloper_addGeneratedStyles(generatedDocument);
  2293.  
  2294.     headerElement = generatedDocument.createElement("h1");
  2295.     headerElement.appendChild(generatedDocument.createTextNode(title));
  2296.     bodyElement.appendChild(headerElement);
  2297.  
  2298.     preElement = generatedDocument.createElement("pre");
  2299.     preElement.appendChild(generatedDocument.createTextNode(responseHeaders + "\n" + request.status + " " + request.statusText));
  2300.     bodyElement.appendChild(preElement);
  2301.  
  2302.     // If the open tabs in background preference is set to true
  2303.     if(webdeveloper_getBooleanPreference("webdeveloper.open.tabs.background", true))
  2304.     {
  2305.         getBrowser().selectedTab = oldTab;
  2306.     }
  2307. }
  2308.